package helper

import (	
	"regexp"
	"strings"
)

func ValidateDomainName(domainName string) (valid bool) {
	matched, _ := regexp.MatchString("^[A-Za-z0-9-]+(\\.[A-Za-z0-9-]+){0,4}(\\.[A-Za-z]{2,})$", domainName)
	valid = matched
	return
}
func GetDomainNameFromURL(controllerPath string, url string) (domain string) {
	domain = strings.Replace(url, controllerPath, "", -1)
	domain = strings.Replace(domain, "https:", "", -1)
	domain = strings.Replace(domain, "http:", "", -1)
	domain = strings.Replace(domain, "/", "", -1)
	domain = strings.Replace(domain, "www.", "", -1)
	return
}

